/**
 * TODO:文件描述
 *
 * @title calcServer
 * @projectName grpcDemo
 * @author niuk
 * @date 2024/4/8 17:30
 */

package calc

import "context"

const version = "V1.0.0"

type Server struct {
	UnimplementedCalcServer
}

func (Server) Sum(ctx context.Context, request *CalcRequest) (*SInt, error) {
	return &SInt{Num: request.GetA() + request.GetB()}, nil
}

func (Server) Version(ctx context.Context, empty *Empty) (*String, error) {
	return &String{Str: version}, nil
}

func (Server) SumArray(ctx context.Context, a *Array) (*SInt, error) {
	var sum int32
	for i := range a.Nums {
		sum += a.Nums[i]
	}
	return &SInt{Num: sum}, nil
}

func (Server) GetNums(req *SInt, stream Calc_GetNumsServer) error {
	return nil
}

func (Server) mustEmbedUnimplementedCalcServer() {}
